package com.tjp.eight.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;

/**
 * Created by Administrator on 2017/4/1.
 */

public class EditTextPreIme extends EditText {

    public EditTextPreIme(Context context) {
        super(context);
    }

    public EditTextPreIme(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public EditTextPreIme(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }


    @Override
    public boolean dispatchKeyEventPreIme(KeyEvent event) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            if (dismissSomething != null) {
                dismissSomething.dismissT();
            }
        }
        return super.dispatchKeyEventPreIme(event);
    }

    public DismissSomething dismissSomething;

    public void setDismissSomething(DismissSomething something) {
        dismissSomething = something;
    }

    public interface DismissSomething {
        void dismissT();
    }
}
